//
//  UIWindow+Ex.swift
//
//
//  Created by rui on 2024/5/7.
//

import UIKit

public extension UIWindow {
    static func getKeyWindow() -> UIWindow? {
        var result: UIWindow?
        if #available(iOS 13.0, *) {
            result = UIApplication.shared.connectedScenes
                .filter({$0 is UIWindowScene})
                .map({($0 as! UIWindowScene).windows})
                .first?
                .filter({$0.isKeyWindow}).first
        } else {
            result = UIApplication.shared.keyWindow
        }
        return result
    }
}
